/**
 * Autogenerated by Thrift Compiler (0.19.0)
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Thrift;
using Thrift.Collections;
using Thrift.Protocol;
using Thrift.Protocol.Entities;
using Thrift.Protocol.Utilities;
using Thrift.Transport;
using Thrift.Transport.Client;
using Thrift.Transport.Server;
using Thrift.Processor;


#nullable enable                 // requires C# 8.0
#pragma warning disable IDE0079  // remove unnecessary pragmas
#pragma warning disable IDE0017  // object init can be simplified
#pragma warning disable IDE0028  // collection init can be simplified
#pragma warning disable IDE1006  // parts of the code use IDL spelling
#pragma warning disable CA1822   // empty DeepCopy() methods still non-static

namespace QueryCat.Plugins.Sdk
{
  public partial class PluginsManager
  {
    public interface IAsync
    {
      global::System.Threading.Tasks.Task<global::QueryCat.Plugins.Sdk.RegistrationResult> RegisterPluginAsync(string auth_token, string callback_uri, global::QueryCat.Plugins.Sdk.PluginData? plugin_data, CancellationToken cancellationToken = default);

      global::System.Threading.Tasks.Task<global::QueryCat.Plugins.Sdk.VariantValue> CallFunctionAsync(string function_name, List<global::QueryCat.Plugins.Sdk.VariantValue>? @args, int object_handle, CancellationToken cancellationToken = default);

      global::System.Threading.Tasks.Task<global::QueryCat.Plugins.Sdk.VariantValue> RunQueryAsync(string @query, Dictionary<string, global::QueryCat.Plugins.Sdk.VariantValue>? @parameters, CancellationToken cancellationToken = default);

      global::System.Threading.Tasks.Task SetConfigValueAsync(string @key, global::QueryCat.Plugins.Sdk.VariantValue? @value, CancellationToken cancellationToken = default);

      global::System.Threading.Tasks.Task<global::QueryCat.Plugins.Sdk.VariantValue> GetConfigValueAsync(string @key, CancellationToken cancellationToken = default);

      global::System.Threading.Tasks.Task LogAsync(global::QueryCat.Plugins.Sdk.LogLevel @level, string @message, List<string>? @arguments, CancellationToken cancellationToken = default);

    }


    public class Client : TBaseClient, IDisposable, IAsync
    {
      public Client(TProtocol protocol) : this(protocol, protocol)
      {
      }

      public Client(TProtocol inputProtocol, TProtocol outputProtocol) : base(inputProtocol, outputProtocol)
      {
      }

      public async global::System.Threading.Tasks.Task<global::QueryCat.Plugins.Sdk.RegistrationResult> RegisterPluginAsync(string auth_token, string callback_uri, global::QueryCat.Plugins.Sdk.PluginData? plugin_data, CancellationToken cancellationToken = default)
      {
        await send_RegisterPluginAsync(auth_token, callback_uri, plugin_data, cancellationToken);
        return await recv_RegisterPluginAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task send_RegisterPluginAsync(string auth_token, string callback_uri, global::QueryCat.Plugins.Sdk.PluginData? plugin_data, CancellationToken cancellationToken = default)
      {
        await OutputProtocol.WriteMessageBeginAsync(new TMessage("RegisterPlugin", TMessageType.Call, SeqId), cancellationToken);
        
        var tmp64 = new InternalStructs.RegisterPlugin_args() {
          AuthToken = auth_token,
          CallbackUri = callback_uri,
          PluginData = plugin_data,
        };
        
        await tmp64.WriteAsync(OutputProtocol, cancellationToken);
        await OutputProtocol.WriteMessageEndAsync(cancellationToken);
        await OutputProtocol.Transport.FlushAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task<global::QueryCat.Plugins.Sdk.RegistrationResult> recv_RegisterPluginAsync(CancellationToken cancellationToken = default)
      {
        
        var tmp65 = await InputProtocol.ReadMessageBeginAsync(cancellationToken);
        if (tmp65.Type == TMessageType.Exception)
        {
          var tmp66 = await TApplicationException.ReadAsync(InputProtocol, cancellationToken);
          await InputProtocol.ReadMessageEndAsync(cancellationToken);
          throw tmp66;
        }

        var tmp67 = new InternalStructs.RegisterPlugin_result();
        await tmp67.ReadAsync(InputProtocol, cancellationToken);
        await InputProtocol.ReadMessageEndAsync(cancellationToken);
        if (tmp67.__isset.success)
        {
          return tmp67.Success!;
        }
        if (tmp67.__isset.@e)
        {
          throw tmp67.E!;
        }
        throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "RegisterPluginAsync failed: unknown result");
      }

      public async global::System.Threading.Tasks.Task<global::QueryCat.Plugins.Sdk.VariantValue> CallFunctionAsync(string function_name, List<global::QueryCat.Plugins.Sdk.VariantValue>? @args, int object_handle, CancellationToken cancellationToken = default)
      {
        await send_CallFunctionAsync(function_name, @args, object_handle, cancellationToken);
        return await recv_CallFunctionAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task send_CallFunctionAsync(string function_name, List<global::QueryCat.Plugins.Sdk.VariantValue>? @args, int object_handle, CancellationToken cancellationToken = default)
      {
        await OutputProtocol.WriteMessageBeginAsync(new TMessage("CallFunction", TMessageType.Call, SeqId), cancellationToken);
        
        var tmp68 = new InternalStructs.CallFunction_args() {
          FunctionName = function_name,
          Args = @args,
          ObjectHandle = object_handle,
        };
        
        await tmp68.WriteAsync(OutputProtocol, cancellationToken);
        await OutputProtocol.WriteMessageEndAsync(cancellationToken);
        await OutputProtocol.Transport.FlushAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task<global::QueryCat.Plugins.Sdk.VariantValue> recv_CallFunctionAsync(CancellationToken cancellationToken = default)
      {
        
        var tmp69 = await InputProtocol.ReadMessageBeginAsync(cancellationToken);
        if (tmp69.Type == TMessageType.Exception)
        {
          var tmp70 = await TApplicationException.ReadAsync(InputProtocol, cancellationToken);
          await InputProtocol.ReadMessageEndAsync(cancellationToken);
          throw tmp70;
        }

        var tmp71 = new InternalStructs.CallFunction_result();
        await tmp71.ReadAsync(InputProtocol, cancellationToken);
        await InputProtocol.ReadMessageEndAsync(cancellationToken);
        if (tmp71.__isset.success)
        {
          return tmp71.Success!;
        }
        if (tmp71.__isset.@e)
        {
          throw tmp71.E!;
        }
        throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "CallFunctionAsync failed: unknown result");
      }

      public async global::System.Threading.Tasks.Task<global::QueryCat.Plugins.Sdk.VariantValue> RunQueryAsync(string @query, Dictionary<string, global::QueryCat.Plugins.Sdk.VariantValue>? @parameters, CancellationToken cancellationToken = default)
      {
        await send_RunQueryAsync(@query, @parameters, cancellationToken);
        return await recv_RunQueryAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task send_RunQueryAsync(string @query, Dictionary<string, global::QueryCat.Plugins.Sdk.VariantValue>? @parameters, CancellationToken cancellationToken = default)
      {
        await OutputProtocol.WriteMessageBeginAsync(new TMessage("RunQuery", TMessageType.Call, SeqId), cancellationToken);
        
        var tmp72 = new InternalStructs.RunQuery_args() {
          Query = @query,
          Parameters = @parameters,
        };
        
        await tmp72.WriteAsync(OutputProtocol, cancellationToken);
        await OutputProtocol.WriteMessageEndAsync(cancellationToken);
        await OutputProtocol.Transport.FlushAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task<global::QueryCat.Plugins.Sdk.VariantValue> recv_RunQueryAsync(CancellationToken cancellationToken = default)
      {
        
        var tmp73 = await InputProtocol.ReadMessageBeginAsync(cancellationToken);
        if (tmp73.Type == TMessageType.Exception)
        {
          var tmp74 = await TApplicationException.ReadAsync(InputProtocol, cancellationToken);
          await InputProtocol.ReadMessageEndAsync(cancellationToken);
          throw tmp74;
        }

        var tmp75 = new InternalStructs.RunQuery_result();
        await tmp75.ReadAsync(InputProtocol, cancellationToken);
        await InputProtocol.ReadMessageEndAsync(cancellationToken);
        if (tmp75.__isset.success)
        {
          return tmp75.Success!;
        }
        if (tmp75.__isset.@e)
        {
          throw tmp75.E!;
        }
        throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "RunQueryAsync failed: unknown result");
      }

      public async global::System.Threading.Tasks.Task SetConfigValueAsync(string @key, global::QueryCat.Plugins.Sdk.VariantValue? @value, CancellationToken cancellationToken = default)
      {
        await send_SetConfigValueAsync(@key, @value, cancellationToken);
        await recv_SetConfigValueAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task send_SetConfigValueAsync(string @key, global::QueryCat.Plugins.Sdk.VariantValue? @value, CancellationToken cancellationToken = default)
      {
        await OutputProtocol.WriteMessageBeginAsync(new TMessage("SetConfigValue", TMessageType.Call, SeqId), cancellationToken);
        
        var tmp76 = new InternalStructs.SetConfigValue_args() {
          Key = @key,
          Value = @value,
        };
        
        await tmp76.WriteAsync(OutputProtocol, cancellationToken);
        await OutputProtocol.WriteMessageEndAsync(cancellationToken);
        await OutputProtocol.Transport.FlushAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task recv_SetConfigValueAsync(CancellationToken cancellationToken = default)
      {
        
        var tmp77 = await InputProtocol.ReadMessageBeginAsync(cancellationToken);
        if (tmp77.Type == TMessageType.Exception)
        {
          var tmp78 = await TApplicationException.ReadAsync(InputProtocol, cancellationToken);
          await InputProtocol.ReadMessageEndAsync(cancellationToken);
          throw tmp78;
        }

        var tmp79 = new InternalStructs.SetConfigValue_result();
        await tmp79.ReadAsync(InputProtocol, cancellationToken);
        await InputProtocol.ReadMessageEndAsync(cancellationToken);
        if (tmp79.__isset.@e)
        {
          throw tmp79.E!;
        }
      }

      public async global::System.Threading.Tasks.Task<global::QueryCat.Plugins.Sdk.VariantValue> GetConfigValueAsync(string @key, CancellationToken cancellationToken = default)
      {
        await send_GetConfigValueAsync(@key, cancellationToken);
        return await recv_GetConfigValueAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task send_GetConfigValueAsync(string @key, CancellationToken cancellationToken = default)
      {
        await OutputProtocol.WriteMessageBeginAsync(new TMessage("GetConfigValue", TMessageType.Call, SeqId), cancellationToken);
        
        var tmp80 = new InternalStructs.GetConfigValue_args() {
          Key = @key,
        };
        
        await tmp80.WriteAsync(OutputProtocol, cancellationToken);
        await OutputProtocol.WriteMessageEndAsync(cancellationToken);
        await OutputProtocol.Transport.FlushAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task<global::QueryCat.Plugins.Sdk.VariantValue> recv_GetConfigValueAsync(CancellationToken cancellationToken = default)
      {
        
        var tmp81 = await InputProtocol.ReadMessageBeginAsync(cancellationToken);
        if (tmp81.Type == TMessageType.Exception)
        {
          var tmp82 = await TApplicationException.ReadAsync(InputProtocol, cancellationToken);
          await InputProtocol.ReadMessageEndAsync(cancellationToken);
          throw tmp82;
        }

        var tmp83 = new InternalStructs.GetConfigValue_result();
        await tmp83.ReadAsync(InputProtocol, cancellationToken);
        await InputProtocol.ReadMessageEndAsync(cancellationToken);
        if (tmp83.__isset.success)
        {
          return tmp83.Success!;
        }
        if (tmp83.__isset.@e)
        {
          throw tmp83.E!;
        }
        throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "GetConfigValueAsync failed: unknown result");
      }

      public async global::System.Threading.Tasks.Task LogAsync(global::QueryCat.Plugins.Sdk.LogLevel @level, string @message, List<string>? @arguments, CancellationToken cancellationToken = default)
      {
        await send_LogAsync(@level, @message, @arguments, cancellationToken);
        await recv_LogAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task send_LogAsync(global::QueryCat.Plugins.Sdk.LogLevel @level, string @message, List<string>? @arguments, CancellationToken cancellationToken = default)
      {
        await OutputProtocol.WriteMessageBeginAsync(new TMessage("Log", TMessageType.Call, SeqId), cancellationToken);
        
        var tmp84 = new InternalStructs.Log_args() {
          Level = @level,
          Message = @message,
          Arguments = @arguments,
        };
        
        await tmp84.WriteAsync(OutputProtocol, cancellationToken);
        await OutputProtocol.WriteMessageEndAsync(cancellationToken);
        await OutputProtocol.Transport.FlushAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task recv_LogAsync(CancellationToken cancellationToken = default)
      {
        
        var tmp85 = await InputProtocol.ReadMessageBeginAsync(cancellationToken);
        if (tmp85.Type == TMessageType.Exception)
        {
          var tmp86 = await TApplicationException.ReadAsync(InputProtocol, cancellationToken);
          await InputProtocol.ReadMessageEndAsync(cancellationToken);
          throw tmp86;
        }

        var tmp87 = new InternalStructs.Log_result();
        await tmp87.ReadAsync(InputProtocol, cancellationToken);
        await InputProtocol.ReadMessageEndAsync(cancellationToken);
        if (tmp87.__isset.@e)
        {
          throw tmp87.E!;
        }
      }

    }

    public class AsyncProcessor : ITAsyncProcessor
    {
      private readonly IAsync _iAsync;
      private readonly ILogger<AsyncProcessor>? _logger;

      public AsyncProcessor(IAsync iAsync, ILogger<AsyncProcessor>? logger = default)
      {
        _iAsync = iAsync ?? throw new ArgumentNullException(nameof(iAsync));
        _logger = logger;
        processMap_["RegisterPlugin"] = RegisterPlugin_ProcessAsync;
        processMap_["CallFunction"] = CallFunction_ProcessAsync;
        processMap_["RunQuery"] = RunQuery_ProcessAsync;
        processMap_["SetConfigValue"] = SetConfigValue_ProcessAsync;
        processMap_["GetConfigValue"] = GetConfigValue_ProcessAsync;
        processMap_["Log"] = Log_ProcessAsync;
      }

      protected delegate global::System.Threading.Tasks.Task ProcessFunction(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken cancellationToken);
      protected Dictionary<string, ProcessFunction> processMap_ = new();

      public async Task<bool> ProcessAsync(TProtocol iprot, TProtocol oprot)
      {
        return await ProcessAsync(iprot, oprot, CancellationToken.None);
      }

      public async Task<bool> ProcessAsync(TProtocol iprot, TProtocol oprot, CancellationToken cancellationToken)
      {
        try
        {
          var msg = await iprot.ReadMessageBeginAsync(cancellationToken);

          processMap_.TryGetValue(msg.Name, out var fn);

          if (fn == null)
          {
            await TProtocolUtil.SkipAsync(iprot, TType.Struct, cancellationToken);
            await iprot.ReadMessageEndAsync(cancellationToken);
            var x = new TApplicationException (TApplicationException.ExceptionType.UnknownMethod, "Invalid method name: '" + msg.Name + "'");
            await oprot.WriteMessageBeginAsync(new TMessage(msg.Name, TMessageType.Exception, msg.SeqID), cancellationToken);
            await x.WriteAsync(oprot, cancellationToken);
            await oprot.WriteMessageEndAsync(cancellationToken);
            await oprot.Transport.FlushAsync(cancellationToken);
            return true;
          }

          await fn(msg.SeqID, iprot, oprot, cancellationToken);

        }
        catch (IOException)
        {
          return false;
        }

        return true;
      }

      public async global::System.Threading.Tasks.Task RegisterPlugin_ProcessAsync(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken cancellationToken)
      {
        var tmp88 = new InternalStructs.RegisterPlugin_args();
        await tmp88.ReadAsync(iprot, cancellationToken);
        await iprot.ReadMessageEndAsync(cancellationToken);
        var tmp89 = new InternalStructs.RegisterPlugin_result();
        try
        {
          try
          {
            tmp89.Success = await _iAsync.RegisterPluginAsync(tmp88.AuthToken, tmp88.CallbackUri, tmp88.PluginData, cancellationToken);
          }
          catch (global::QueryCat.Plugins.Sdk.QueryCatPluginException tmp90)
          {
            tmp89.E = tmp90;
          }
          await oprot.WriteMessageBeginAsync(new TMessage("RegisterPlugin", TMessageType.Reply, seqid), cancellationToken); 
          await tmp89.WriteAsync(oprot, cancellationToken);
        }
        catch (TTransportException)
        {
          throw;
        }
        catch (Exception tmp91)
        {
          var tmp92 = $"Error occurred in {GetType().FullName}: {tmp91.Message}";
          if(_logger != null)
            _logger.LogError("{Exception}, {Message}", tmp91, tmp92);
          else
            Console.Error.WriteLine(tmp92);
          var tmp93 = new TApplicationException(TApplicationException.ExceptionType.InternalError," Internal error.");
          await oprot.WriteMessageBeginAsync(new TMessage("RegisterPlugin", TMessageType.Exception, seqid), cancellationToken);
          await tmp93.WriteAsync(oprot, cancellationToken);
        }
        await oprot.WriteMessageEndAsync(cancellationToken);
        await oprot.Transport.FlushAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task CallFunction_ProcessAsync(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken cancellationToken)
      {
        var tmp94 = new InternalStructs.CallFunction_args();
        await tmp94.ReadAsync(iprot, cancellationToken);
        await iprot.ReadMessageEndAsync(cancellationToken);
        var tmp95 = new InternalStructs.CallFunction_result();
        try
        {
          try
          {
            tmp95.Success = await _iAsync.CallFunctionAsync(tmp94.FunctionName, tmp94.Args, tmp94.ObjectHandle, cancellationToken);
          }
          catch (global::QueryCat.Plugins.Sdk.QueryCatPluginException tmp96)
          {
            tmp95.E = tmp96;
          }
          await oprot.WriteMessageBeginAsync(new TMessage("CallFunction", TMessageType.Reply, seqid), cancellationToken); 
          await tmp95.WriteAsync(oprot, cancellationToken);
        }
        catch (TTransportException)
        {
          throw;
        }
        catch (Exception tmp97)
        {
          var tmp98 = $"Error occurred in {GetType().FullName}: {tmp97.Message}";
          if(_logger != null)
            _logger.LogError("{Exception}, {Message}", tmp97, tmp98);
          else
            Console.Error.WriteLine(tmp98);
          var tmp99 = new TApplicationException(TApplicationException.ExceptionType.InternalError," Internal error.");
          await oprot.WriteMessageBeginAsync(new TMessage("CallFunction", TMessageType.Exception, seqid), cancellationToken);
          await tmp99.WriteAsync(oprot, cancellationToken);
        }
        await oprot.WriteMessageEndAsync(cancellationToken);
        await oprot.Transport.FlushAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task RunQuery_ProcessAsync(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken cancellationToken)
      {
        var tmp100 = new InternalStructs.RunQuery_args();
        await tmp100.ReadAsync(iprot, cancellationToken);
        await iprot.ReadMessageEndAsync(cancellationToken);
        var tmp101 = new InternalStructs.RunQuery_result();
        try
        {
          try
          {
            tmp101.Success = await _iAsync.RunQueryAsync(tmp100.Query, tmp100.Parameters, cancellationToken);
          }
          catch (global::QueryCat.Plugins.Sdk.QueryCatPluginException tmp102)
          {
            tmp101.E = tmp102;
          }
          await oprot.WriteMessageBeginAsync(new TMessage("RunQuery", TMessageType.Reply, seqid), cancellationToken); 
          await tmp101.WriteAsync(oprot, cancellationToken);
        }
        catch (TTransportException)
        {
          throw;
        }
        catch (Exception tmp103)
        {
          var tmp104 = $"Error occurred in {GetType().FullName}: {tmp103.Message}";
          if(_logger != null)
            _logger.LogError("{Exception}, {Message}", tmp103, tmp104);
          else
            Console.Error.WriteLine(tmp104);
          var tmp105 = new TApplicationException(TApplicationException.ExceptionType.InternalError," Internal error.");
          await oprot.WriteMessageBeginAsync(new TMessage("RunQuery", TMessageType.Exception, seqid), cancellationToken);
          await tmp105.WriteAsync(oprot, cancellationToken);
        }
        await oprot.WriteMessageEndAsync(cancellationToken);
        await oprot.Transport.FlushAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task SetConfigValue_ProcessAsync(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken cancellationToken)
      {
        var tmp106 = new InternalStructs.SetConfigValue_args();
        await tmp106.ReadAsync(iprot, cancellationToken);
        await iprot.ReadMessageEndAsync(cancellationToken);
        var tmp107 = new InternalStructs.SetConfigValue_result();
        try
        {
          try
          {
            await _iAsync.SetConfigValueAsync(tmp106.Key, tmp106.Value, cancellationToken);
          }
          catch (global::QueryCat.Plugins.Sdk.QueryCatPluginException tmp108)
          {
            tmp107.E = tmp108;
          }
          await oprot.WriteMessageBeginAsync(new TMessage("SetConfigValue", TMessageType.Reply, seqid), cancellationToken); 
          await tmp107.WriteAsync(oprot, cancellationToken);
        }
        catch (TTransportException)
        {
          throw;
        }
        catch (Exception tmp109)
        {
          var tmp110 = $"Error occurred in {GetType().FullName}: {tmp109.Message}";
          if(_logger != null)
            _logger.LogError("{Exception}, {Message}", tmp109, tmp110);
          else
            Console.Error.WriteLine(tmp110);
          var tmp111 = new TApplicationException(TApplicationException.ExceptionType.InternalError," Internal error.");
          await oprot.WriteMessageBeginAsync(new TMessage("SetConfigValue", TMessageType.Exception, seqid), cancellationToken);
          await tmp111.WriteAsync(oprot, cancellationToken);
        }
        await oprot.WriteMessageEndAsync(cancellationToken);
        await oprot.Transport.FlushAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task GetConfigValue_ProcessAsync(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken cancellationToken)
      {
        var tmp112 = new InternalStructs.GetConfigValue_args();
        await tmp112.ReadAsync(iprot, cancellationToken);
        await iprot.ReadMessageEndAsync(cancellationToken);
        var tmp113 = new InternalStructs.GetConfigValue_result();
        try
        {
          try
          {
            tmp113.Success = await _iAsync.GetConfigValueAsync(tmp112.Key, cancellationToken);
          }
          catch (global::QueryCat.Plugins.Sdk.QueryCatPluginException tmp114)
          {
            tmp113.E = tmp114;
          }
          await oprot.WriteMessageBeginAsync(new TMessage("GetConfigValue", TMessageType.Reply, seqid), cancellationToken); 
          await tmp113.WriteAsync(oprot, cancellationToken);
        }
        catch (TTransportException)
        {
          throw;
        }
        catch (Exception tmp115)
        {
          var tmp116 = $"Error occurred in {GetType().FullName}: {tmp115.Message}";
          if(_logger != null)
            _logger.LogError("{Exception}, {Message}", tmp115, tmp116);
          else
            Console.Error.WriteLine(tmp116);
          var tmp117 = new TApplicationException(TApplicationException.ExceptionType.InternalError," Internal error.");
          await oprot.WriteMessageBeginAsync(new TMessage("GetConfigValue", TMessageType.Exception, seqid), cancellationToken);
          await tmp117.WriteAsync(oprot, cancellationToken);
        }
        await oprot.WriteMessageEndAsync(cancellationToken);
        await oprot.Transport.FlushAsync(cancellationToken);
      }

      public async global::System.Threading.Tasks.Task Log_ProcessAsync(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken cancellationToken)
      {
        var tmp118 = new InternalStructs.Log_args();
        await tmp118.ReadAsync(iprot, cancellationToken);
        await iprot.ReadMessageEndAsync(cancellationToken);
        var tmp119 = new InternalStructs.Log_result();
        try
        {
          try
          {
            await _iAsync.LogAsync(tmp118.Level, tmp118.Message, tmp118.Arguments, cancellationToken);
          }
          catch (global::QueryCat.Plugins.Sdk.QueryCatPluginException tmp120)
          {
            tmp119.E = tmp120;
          }
          await oprot.WriteMessageBeginAsync(new TMessage("Log", TMessageType.Reply, seqid), cancellationToken); 
          await tmp119.WriteAsync(oprot, cancellationToken);
        }
        catch (TTransportException)
        {
          throw;
        }
        catch (Exception tmp121)
        {
          var tmp122 = $"Error occurred in {GetType().FullName}: {tmp121.Message}";
          if(_logger != null)
            _logger.LogError("{Exception}, {Message}", tmp121, tmp122);
          else
            Console.Error.WriteLine(tmp122);
          var tmp123 = new TApplicationException(TApplicationException.ExceptionType.InternalError," Internal error.");
          await oprot.WriteMessageBeginAsync(new TMessage("Log", TMessageType.Exception, seqid), cancellationToken);
          await tmp123.WriteAsync(oprot, cancellationToken);
        }
        await oprot.WriteMessageEndAsync(cancellationToken);
        await oprot.Transport.FlushAsync(cancellationToken);
      }

    }

    public class InternalStructs
    {

      public partial class RegisterPlugin_args : TBase
      {

        public string AuthToken { get; set; } = string.Empty;

        public string CallbackUri { get; set; } = string.Empty;

        public global::QueryCat.Plugins.Sdk.PluginData? PluginData { get; set; }

        public RegisterPlugin_args()
        {
        }

        public RegisterPlugin_args(string auth_token, string callback_uri, global::QueryCat.Plugins.Sdk.PluginData? plugin_data) : this()
        {
          this.AuthToken = auth_token;
          this.CallbackUri = callback_uri;
          this.PluginData = plugin_data;
        }

        public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
          iprot.IncrementRecursionDepth();
          try
          {
            bool isset_auth_token = false;
            bool isset_callback_uri = false;
            bool isset_plugin_data = false;
            TField field;
            await iprot.ReadStructBeginAsync(cancellationToken);
            while (true)
            {
              field = await iprot.ReadFieldBeginAsync(cancellationToken);
              if (field.Type == TType.Stop)
              {
                break;
              }

              switch (field.ID)
              {
                case 1:
                  if (field.Type == TType.String)
                  {
                    AuthToken = await iprot.ReadStringAsync(cancellationToken);
                    isset_auth_token = true;
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                case 2:
                  if (field.Type == TType.String)
                  {
                    CallbackUri = await iprot.ReadStringAsync(cancellationToken);
                    isset_callback_uri = true;
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                case 3:
                  if (field.Type == TType.Struct)
                  {
                    PluginData = new global::QueryCat.Plugins.Sdk.PluginData();
                    await PluginData.ReadAsync(iprot, cancellationToken);
                    isset_plugin_data = true;
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                default: 
                  await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  break;
              }

              await iprot.ReadFieldEndAsync(cancellationToken);
            }

            await iprot.ReadStructEndAsync(cancellationToken);
            if (!isset_auth_token)
            {
              throw new TProtocolException(TProtocolException.INVALID_DATA);
            }
            if (!isset_callback_uri)
            {
              throw new TProtocolException(TProtocolException.INVALID_DATA);
            }
            if (!isset_plugin_data)
            {
              throw new TProtocolException(TProtocolException.INVALID_DATA);
            }
          }
          finally
          {
            iprot.DecrementRecursionDepth();
          }
        }

        public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
        {
          oprot.IncrementRecursionDepth();
          try
          {
            var tmp124 = new TStruct("RegisterPlugin_args");
            await oprot.WriteStructBeginAsync(tmp124, cancellationToken);
            var tmp125 = new TField();
            if((AuthToken != null))
            {
              tmp125.Name = "auth_token";
              tmp125.Type = TType.String;
              tmp125.ID = 1;
              await oprot.WriteFieldBeginAsync(tmp125, cancellationToken);
              await oprot.WriteStringAsync(AuthToken, cancellationToken);
              await oprot.WriteFieldEndAsync(cancellationToken);
            }
            if((CallbackUri != null))
            {
              tmp125.Name = "callback_uri";
              tmp125.Type = TType.String;
              tmp125.ID = 2;
              await oprot.WriteFieldBeginAsync(tmp125, cancellationToken);
              await oprot.WriteStringAsync(CallbackUri, cancellationToken);
              await oprot.WriteFieldEndAsync(cancellationToken);
            }
            if((PluginData != null))
            {
              tmp125.Name = "plugin_data";
              tmp125.Type = TType.Struct;
              tmp125.ID = 3;
              await oprot.WriteFieldBeginAsync(tmp125, cancellationToken);
              await PluginData.WriteAsync(oprot, cancellationToken);
              await oprot.WriteFieldEndAsync(cancellationToken);
            }
            await oprot.WriteFieldStopAsync(cancellationToken);
            await oprot.WriteStructEndAsync(cancellationToken);
          }
          finally
          {
            oprot.DecrementRecursionDepth();
          }
        }

        public override bool Equals(object? that)
        {
          if (that is not RegisterPlugin_args other) return false;
          if (ReferenceEquals(this, other)) return true;
          return global::System.Object.Equals(AuthToken, other.AuthToken)
            && global::System.Object.Equals(CallbackUri, other.CallbackUri)
            && global::System.Object.Equals(PluginData, other.PluginData);
        }

        public override int GetHashCode() {
          int hashcode = 157;
          unchecked {
            if((AuthToken != null))
            {
              hashcode = (hashcode * 397) + AuthToken.GetHashCode();
            }
            if((CallbackUri != null))
            {
              hashcode = (hashcode * 397) + CallbackUri.GetHashCode();
            }
            if((PluginData != null))
            {
              hashcode = (hashcode * 397) + PluginData.GetHashCode();
            }
          }
          return hashcode;
        }

        public override string ToString()
        {
          var tmp126 = new StringBuilder("RegisterPlugin_args(");
          if((AuthToken != null))
          {
            tmp126.Append(", AuthToken: ");
            AuthToken.ToString(tmp126);
          }
          if((CallbackUri != null))
          {
            tmp126.Append(", CallbackUri: ");
            CallbackUri.ToString(tmp126);
          }
          if((PluginData != null))
          {
            tmp126.Append(", PluginData: ");
            PluginData.ToString(tmp126);
          }
          tmp126.Append(')');
          return tmp126.ToString();
        }
      }


      public partial class RegisterPlugin_result : TBase
      {
        private global::QueryCat.Plugins.Sdk.RegistrationResult? _success;
        private global::QueryCat.Plugins.Sdk.QueryCatPluginException? _e;

        public global::QueryCat.Plugins.Sdk.RegistrationResult? Success
        {
          get
          {
            return _success;
          }
          set
          {
            __isset.@success = true;
            this._success = value;
          }
        }

        public global::QueryCat.Plugins.Sdk.QueryCatPluginException? E
        {
          get
          {
            return _e;
          }
          set
          {
            __isset.@e = true;
            this._e = value;
          }
        }


        public Isset __isset;
        public struct Isset
        {
          public bool @success;
          public bool @e;
        }

        public RegisterPlugin_result()
        {
        }

        public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
          iprot.IncrementRecursionDepth();
          try
          {
            TField field;
            await iprot.ReadStructBeginAsync(cancellationToken);
            while (true)
            {
              field = await iprot.ReadFieldBeginAsync(cancellationToken);
              if (field.Type == TType.Stop)
              {
                break;
              }

              switch (field.ID)
              {
                case 0:
                  if (field.Type == TType.Struct)
                  {
                    Success = new global::QueryCat.Plugins.Sdk.RegistrationResult();
                    await Success.ReadAsync(iprot, cancellationToken);
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                case 1:
                  if (field.Type == TType.Struct)
                  {
                    E = new global::QueryCat.Plugins.Sdk.QueryCatPluginException();
                    await E.ReadAsync(iprot, cancellationToken);
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                default: 
                  await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  break;
              }

              await iprot.ReadFieldEndAsync(cancellationToken);
            }

            await iprot.ReadStructEndAsync(cancellationToken);
          }
          finally
          {
            iprot.DecrementRecursionDepth();
          }
        }

        public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
        {
          oprot.IncrementRecursionDepth();
          try
          {
            var tmp128 = new TStruct("RegisterPlugin_result");
            await oprot.WriteStructBeginAsync(tmp128, cancellationToken);
            var tmp129 = new TField();

            if(this.__isset.@success)
            {
              if (Success != null)
              {
                tmp129.Name = "Success";
                tmp129.Type = TType.Struct;
                tmp129.ID = 0;
                await oprot.WriteFieldBeginAsync(tmp129, cancellationToken);
                await Success.WriteAsync(oprot, cancellationToken);
                await oprot.WriteFieldEndAsync(cancellationToken);
              }
            }
            else if(this.__isset.@e)
            {
              if (E != null)
              {
                tmp129.Name = "E";
                tmp129.Type = TType.Struct;
                tmp129.ID = 1;
                await oprot.WriteFieldBeginAsync(tmp129, cancellationToken);
                await E.WriteAsync(oprot, cancellationToken);
                await oprot.WriteFieldEndAsync(cancellationToken);
              }
            }
            await oprot.WriteFieldStopAsync(cancellationToken);
            await oprot.WriteStructEndAsync(cancellationToken);
          }
          finally
          {
            oprot.DecrementRecursionDepth();
          }
        }

        public override bool Equals(object? that)
        {
          if (that is not RegisterPlugin_result other) return false;
          if (ReferenceEquals(this, other)) return true;
          return ((__isset.@success == other.__isset.@success) && ((!__isset.@success) || (global::System.Object.Equals(Success, other.Success))))
            && ((__isset.@e == other.__isset.@e) && ((!__isset.@e) || (global::System.Object.Equals(E, other.E))));
        }

        public override int GetHashCode() {
          int hashcode = 157;
          unchecked {
            if((Success != null) && __isset.@success)
            {
              hashcode = (hashcode * 397) + Success.GetHashCode();
            }
            if((E != null) && __isset.@e)
            {
              hashcode = (hashcode * 397) + E.GetHashCode();
            }
          }
          return hashcode;
        }

        public override string ToString()
        {
          var tmp130 = new StringBuilder("RegisterPlugin_result(");
          int tmp131 = 0;
          if((Success != null) && __isset.@success)
          {
            if(0 < tmp131++) { tmp130.Append(", "); }
            tmp130.Append("Success: ");
            Success.ToString(tmp130);
          }
          if((E != null) && __isset.@e)
          {
            if(0 < tmp131++) { tmp130.Append(", "); }
            tmp130.Append("E: ");
            E.ToString(tmp130);
          }
          tmp130.Append(')');
          return tmp130.ToString();
        }
      }


      public partial class CallFunction_args : TBase
      {
        private int _object_handle;

        public string FunctionName { get; set; } = string.Empty;

        public List<global::QueryCat.Plugins.Sdk.VariantValue>? Args { get; set; }

        public int ObjectHandle
        {
          get
          {
            return _object_handle;
          }
          set
          {
            __isset.object_handle = true;
            this._object_handle = value;
          }
        }


        public Isset __isset;
        public struct Isset
        {
          public bool object_handle;
        }

        public CallFunction_args()
        {
        }

        public CallFunction_args(string function_name, List<global::QueryCat.Plugins.Sdk.VariantValue>? @args) : this()
        {
          this.FunctionName = function_name;
          this.Args = @args;
        }

        public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
          iprot.IncrementRecursionDepth();
          try
          {
            bool isset_function_name = false;
            bool isset_args = false;
            TField field;
            await iprot.ReadStructBeginAsync(cancellationToken);
            while (true)
            {
              field = await iprot.ReadFieldBeginAsync(cancellationToken);
              if (field.Type == TType.Stop)
              {
                break;
              }

              switch (field.ID)
              {
                case 1:
                  if (field.Type == TType.String)
                  {
                    FunctionName = await iprot.ReadStringAsync(cancellationToken);
                    isset_function_name = true;
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                case 2:
                  if (field.Type == TType.List)
                  {
                    {
                      var _list132 = await iprot.ReadListBeginAsync(cancellationToken);
                      Args = new List<global::QueryCat.Plugins.Sdk.VariantValue>(_list132.Count);
                      for(int _i133 = 0; _i133 < _list132.Count; ++_i133)
                      {
                        global::QueryCat.Plugins.Sdk.VariantValue _elem134;
                        _elem134 = new global::QueryCat.Plugins.Sdk.VariantValue();
                        await _elem134.ReadAsync(iprot, cancellationToken);
                        Args.Add(_elem134);
                      }
                      await iprot.ReadListEndAsync(cancellationToken);
                    }
                    isset_args = true;
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                case 3:
                  if (field.Type == TType.I32)
                  {
                    ObjectHandle = await iprot.ReadI32Async(cancellationToken);
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                default: 
                  await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  break;
              }

              await iprot.ReadFieldEndAsync(cancellationToken);
            }

            await iprot.ReadStructEndAsync(cancellationToken);
            if (!isset_function_name)
            {
              throw new TProtocolException(TProtocolException.INVALID_DATA);
            }
            if (!isset_args)
            {
              throw new TProtocolException(TProtocolException.INVALID_DATA);
            }
          }
          finally
          {
            iprot.DecrementRecursionDepth();
          }
        }

        public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
        {
          oprot.IncrementRecursionDepth();
          try
          {
            var tmp135 = new TStruct("CallFunction_args");
            await oprot.WriteStructBeginAsync(tmp135, cancellationToken);
            var tmp136 = new TField();
            if((FunctionName != null))
            {
              tmp136.Name = "function_name";
              tmp136.Type = TType.String;
              tmp136.ID = 1;
              await oprot.WriteFieldBeginAsync(tmp136, cancellationToken);
              await oprot.WriteStringAsync(FunctionName, cancellationToken);
              await oprot.WriteFieldEndAsync(cancellationToken);
            }
            if((Args != null))
            {
              tmp136.Name = "args";
              tmp136.Type = TType.List;
              tmp136.ID = 2;
              await oprot.WriteFieldBeginAsync(tmp136, cancellationToken);
              await oprot.WriteListBeginAsync(new TList(TType.Struct, Args.Count), cancellationToken);
              foreach (global::QueryCat.Plugins.Sdk.VariantValue _iter137 in Args)
              {
                await _iter137.WriteAsync(oprot, cancellationToken);
              }
              await oprot.WriteListEndAsync(cancellationToken);
              await oprot.WriteFieldEndAsync(cancellationToken);
            }
            if(__isset.object_handle)
            {
              tmp136.Name = "object_handle";
              tmp136.Type = TType.I32;
              tmp136.ID = 3;
              await oprot.WriteFieldBeginAsync(tmp136, cancellationToken);
              await oprot.WriteI32Async(ObjectHandle, cancellationToken);
              await oprot.WriteFieldEndAsync(cancellationToken);
            }
            await oprot.WriteFieldStopAsync(cancellationToken);
            await oprot.WriteStructEndAsync(cancellationToken);
          }
          finally
          {
            oprot.DecrementRecursionDepth();
          }
        }

        public override bool Equals(object? that)
        {
          if (that is not CallFunction_args other) return false;
          if (ReferenceEquals(this, other)) return true;
          return global::System.Object.Equals(FunctionName, other.FunctionName)
            && TCollections.Equals(Args, other.Args)
            && ((__isset.object_handle == other.__isset.object_handle) && ((!__isset.object_handle) || (global::System.Object.Equals(ObjectHandle, other.ObjectHandle))));
        }

        public override int GetHashCode() {
          int hashcode = 157;
          unchecked {
            if((FunctionName != null))
            {
              hashcode = (hashcode * 397) + FunctionName.GetHashCode();
            }
            if((Args != null))
            {
              hashcode = (hashcode * 397) + TCollections.GetHashCode(Args);
            }
            if(__isset.object_handle)
            {
              hashcode = (hashcode * 397) + ObjectHandle.GetHashCode();
            }
          }
          return hashcode;
        }

        public override string ToString()
        {
          var tmp138 = new StringBuilder("CallFunction_args(");
          if((FunctionName != null))
          {
            tmp138.Append(", FunctionName: ");
            FunctionName.ToString(tmp138);
          }
          if((Args != null))
          {
            tmp138.Append(", Args: ");
            Args.ToString(tmp138);
          }
          if(__isset.object_handle)
          {
            tmp138.Append(", ObjectHandle: ");
            ObjectHandle.ToString(tmp138);
          }
          tmp138.Append(')');
          return tmp138.ToString();
        }
      }


      public partial class CallFunction_result : TBase
      {
        private global::QueryCat.Plugins.Sdk.VariantValue? _success;
        private global::QueryCat.Plugins.Sdk.QueryCatPluginException? _e;

        public global::QueryCat.Plugins.Sdk.VariantValue? Success
        {
          get
          {
            return _success;
          }
          set
          {
            __isset.@success = true;
            this._success = value;
          }
        }

        public global::QueryCat.Plugins.Sdk.QueryCatPluginException? E
        {
          get
          {
            return _e;
          }
          set
          {
            __isset.@e = true;
            this._e = value;
          }
        }


        public Isset __isset;
        public struct Isset
        {
          public bool @success;
          public bool @e;
        }

        public CallFunction_result()
        {
        }

        public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
          iprot.IncrementRecursionDepth();
          try
          {
            TField field;
            await iprot.ReadStructBeginAsync(cancellationToken);
            while (true)
            {
              field = await iprot.ReadFieldBeginAsync(cancellationToken);
              if (field.Type == TType.Stop)
              {
                break;
              }

              switch (field.ID)
              {
                case 0:
                  if (field.Type == TType.Struct)
                  {
                    Success = new global::QueryCat.Plugins.Sdk.VariantValue();
                    await Success.ReadAsync(iprot, cancellationToken);
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                case 1:
                  if (field.Type == TType.Struct)
                  {
                    E = new global::QueryCat.Plugins.Sdk.QueryCatPluginException();
                    await E.ReadAsync(iprot, cancellationToken);
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                default: 
                  await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  break;
              }

              await iprot.ReadFieldEndAsync(cancellationToken);
            }

            await iprot.ReadStructEndAsync(cancellationToken);
          }
          finally
          {
            iprot.DecrementRecursionDepth();
          }
        }

        public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
        {
          oprot.IncrementRecursionDepth();
          try
          {
            var tmp140 = new TStruct("CallFunction_result");
            await oprot.WriteStructBeginAsync(tmp140, cancellationToken);
            var tmp141 = new TField();

            if(this.__isset.@success)
            {
              if (Success != null)
              {
                tmp141.Name = "Success";
                tmp141.Type = TType.Struct;
                tmp141.ID = 0;
                await oprot.WriteFieldBeginAsync(tmp141, cancellationToken);
                await Success.WriteAsync(oprot, cancellationToken);
                await oprot.WriteFieldEndAsync(cancellationToken);
              }
            }
            else if(this.__isset.@e)
            {
              if (E != null)
              {
                tmp141.Name = "E";
                tmp141.Type = TType.Struct;
                tmp141.ID = 1;
                await oprot.WriteFieldBeginAsync(tmp141, cancellationToken);
                await E.WriteAsync(oprot, cancellationToken);
                await oprot.WriteFieldEndAsync(cancellationToken);
              }
            }
            await oprot.WriteFieldStopAsync(cancellationToken);
            await oprot.WriteStructEndAsync(cancellationToken);
          }
          finally
          {
            oprot.DecrementRecursionDepth();
          }
        }

        public override bool Equals(object? that)
        {
          if (that is not CallFunction_result other) return false;
          if (ReferenceEquals(this, other)) return true;
          return ((__isset.@success == other.__isset.@success) && ((!__isset.@success) || (global::System.Object.Equals(Success, other.Success))))
            && ((__isset.@e == other.__isset.@e) && ((!__isset.@e) || (global::System.Object.Equals(E, other.E))));
        }

        public override int GetHashCode() {
          int hashcode = 157;
          unchecked {
            if((Success != null) && __isset.@success)
            {
              hashcode = (hashcode * 397) + Success.GetHashCode();
            }
            if((E != null) && __isset.@e)
            {
              hashcode = (hashcode * 397) + E.GetHashCode();
            }
          }
          return hashcode;
        }

        public override string ToString()
        {
          var tmp142 = new StringBuilder("CallFunction_result(");
          int tmp143 = 0;
          if((Success != null) && __isset.@success)
          {
            if(0 < tmp143++) { tmp142.Append(", "); }
            tmp142.Append("Success: ");
            Success.ToString(tmp142);
          }
          if((E != null) && __isset.@e)
          {
            if(0 < tmp143++) { tmp142.Append(", "); }
            tmp142.Append("E: ");
            E.ToString(tmp142);
          }
          tmp142.Append(')');
          return tmp142.ToString();
        }
      }


      public partial class RunQuery_args : TBase
      {
        private Dictionary<string, global::QueryCat.Plugins.Sdk.VariantValue>? _parameters;

        public string Query { get; set; } = string.Empty;

        public Dictionary<string, global::QueryCat.Plugins.Sdk.VariantValue>? Parameters
        {
          get
          {
            return _parameters;
          }
          set
          {
            __isset.@parameters = true;
            this._parameters = value;
          }
        }


        public Isset __isset;
        public struct Isset
        {
          public bool @parameters;
        }

        public RunQuery_args()
        {
        }

        public RunQuery_args(string @query) : this()
        {
          this.Query = @query;
        }

        public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
          iprot.IncrementRecursionDepth();
          try
          {
            bool isset_query = false;
            TField field;
            await iprot.ReadStructBeginAsync(cancellationToken);
            while (true)
            {
              field = await iprot.ReadFieldBeginAsync(cancellationToken);
              if (field.Type == TType.Stop)
              {
                break;
              }

              switch (field.ID)
              {
                case 1:
                  if (field.Type == TType.String)
                  {
                    Query = await iprot.ReadStringAsync(cancellationToken);
                    isset_query = true;
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                case 2:
                  if (field.Type == TType.Map)
                  {
                    {
                      var _map144 = await iprot.ReadMapBeginAsync(cancellationToken);
                      Parameters = new Dictionary<string, global::QueryCat.Plugins.Sdk.VariantValue>(_map144.Count);
                      for(int _i145 = 0; _i145 < _map144.Count; ++_i145)
                      {
                        string _key146;
                        global::QueryCat.Plugins.Sdk.VariantValue _val147;
                        _key146 = await iprot.ReadStringAsync(cancellationToken);
                        _val147 = new global::QueryCat.Plugins.Sdk.VariantValue();
                        await _val147.ReadAsync(iprot, cancellationToken);
                        Parameters[_key146] = _val147;
                      }
                      await iprot.ReadMapEndAsync(cancellationToken);
                    }
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                default: 
                  await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  break;
              }

              await iprot.ReadFieldEndAsync(cancellationToken);
            }

            await iprot.ReadStructEndAsync(cancellationToken);
            if (!isset_query)
            {
              throw new TProtocolException(TProtocolException.INVALID_DATA);
            }
          }
          finally
          {
            iprot.DecrementRecursionDepth();
          }
        }

        public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
        {
          oprot.IncrementRecursionDepth();
          try
          {
            var tmp148 = new TStruct("RunQuery_args");
            await oprot.WriteStructBeginAsync(tmp148, cancellationToken);
            var tmp149 = new TField();
            if((Query != null))
            {
              tmp149.Name = "query";
              tmp149.Type = TType.String;
              tmp149.ID = 1;
              await oprot.WriteFieldBeginAsync(tmp149, cancellationToken);
              await oprot.WriteStringAsync(Query, cancellationToken);
              await oprot.WriteFieldEndAsync(cancellationToken);
            }
            if((Parameters != null) && __isset.@parameters)
            {
              tmp149.Name = "parameters";
              tmp149.Type = TType.Map;
              tmp149.ID = 2;
              await oprot.WriteFieldBeginAsync(tmp149, cancellationToken);
              await oprot.WriteMapBeginAsync(new TMap(TType.String, TType.Struct, Parameters.Count), cancellationToken);
              foreach (string _iter150 in Parameters.Keys)
              {
                await oprot.WriteStringAsync(_iter150, cancellationToken);
                await Parameters[_iter150].WriteAsync(oprot, cancellationToken);
              }
              await oprot.WriteMapEndAsync(cancellationToken);
              await oprot.WriteFieldEndAsync(cancellationToken);
            }
            await oprot.WriteFieldStopAsync(cancellationToken);
            await oprot.WriteStructEndAsync(cancellationToken);
          }
          finally
          {
            oprot.DecrementRecursionDepth();
          }
        }

        public override bool Equals(object? that)
        {
          if (that is not RunQuery_args other) return false;
          if (ReferenceEquals(this, other)) return true;
          return global::System.Object.Equals(Query, other.Query)
            && ((__isset.@parameters == other.__isset.@parameters) && ((!__isset.@parameters) || (TCollections.Equals(Parameters, other.Parameters))));
        }

        public override int GetHashCode() {
          int hashcode = 157;
          unchecked {
            if((Query != null))
            {
              hashcode = (hashcode * 397) + Query.GetHashCode();
            }
            if((Parameters != null) && __isset.@parameters)
            {
              hashcode = (hashcode * 397) + TCollections.GetHashCode(Parameters);
            }
          }
          return hashcode;
        }

        public override string ToString()
        {
          var tmp151 = new StringBuilder("RunQuery_args(");
          if((Query != null))
          {
            tmp151.Append(", Query: ");
            Query.ToString(tmp151);
          }
          if((Parameters != null) && __isset.@parameters)
          {
            tmp151.Append(", Parameters: ");
            Parameters.ToString(tmp151);
          }
          tmp151.Append(')');
          return tmp151.ToString();
        }
      }


      public partial class RunQuery_result : TBase
      {
        private global::QueryCat.Plugins.Sdk.VariantValue? _success;
        private global::QueryCat.Plugins.Sdk.QueryCatPluginException? _e;

        public global::QueryCat.Plugins.Sdk.VariantValue? Success
        {
          get
          {
            return _success;
          }
          set
          {
            __isset.@success = true;
            this._success = value;
          }
        }

        public global::QueryCat.Plugins.Sdk.QueryCatPluginException? E
        {
          get
          {
            return _e;
          }
          set
          {
            __isset.@e = true;
            this._e = value;
          }
        }


        public Isset __isset;
        public struct Isset
        {
          public bool @success;
          public bool @e;
        }

        public RunQuery_result()
        {
        }

        public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
          iprot.IncrementRecursionDepth();
          try
          {
            TField field;
            await iprot.ReadStructBeginAsync(cancellationToken);
            while (true)
            {
              field = await iprot.ReadFieldBeginAsync(cancellationToken);
              if (field.Type == TType.Stop)
              {
                break;
              }

              switch (field.ID)
              {
                case 0:
                  if (field.Type == TType.Struct)
                  {
                    Success = new global::QueryCat.Plugins.Sdk.VariantValue();
                    await Success.ReadAsync(iprot, cancellationToken);
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                case 1:
                  if (field.Type == TType.Struct)
                  {
                    E = new global::QueryCat.Plugins.Sdk.QueryCatPluginException();
                    await E.ReadAsync(iprot, cancellationToken);
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                default: 
                  await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  break;
              }

              await iprot.ReadFieldEndAsync(cancellationToken);
            }

            await iprot.ReadStructEndAsync(cancellationToken);
          }
          finally
          {
            iprot.DecrementRecursionDepth();
          }
        }

        public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
        {
          oprot.IncrementRecursionDepth();
          try
          {
            var tmp153 = new TStruct("RunQuery_result");
            await oprot.WriteStructBeginAsync(tmp153, cancellationToken);
            var tmp154 = new TField();

            if(this.__isset.@success)
            {
              if (Success != null)
              {
                tmp154.Name = "Success";
                tmp154.Type = TType.Struct;
                tmp154.ID = 0;
                await oprot.WriteFieldBeginAsync(tmp154, cancellationToken);
                await Success.WriteAsync(oprot, cancellationToken);
                await oprot.WriteFieldEndAsync(cancellationToken);
              }
            }
            else if(this.__isset.@e)
            {
              if (E != null)
              {
                tmp154.Name = "E";
                tmp154.Type = TType.Struct;
                tmp154.ID = 1;
                await oprot.WriteFieldBeginAsync(tmp154, cancellationToken);
                await E.WriteAsync(oprot, cancellationToken);
                await oprot.WriteFieldEndAsync(cancellationToken);
              }
            }
            await oprot.WriteFieldStopAsync(cancellationToken);
            await oprot.WriteStructEndAsync(cancellationToken);
          }
          finally
          {
            oprot.DecrementRecursionDepth();
          }
        }

        public override bool Equals(object? that)
        {
          if (that is not RunQuery_result other) return false;
          if (ReferenceEquals(this, other)) return true;
          return ((__isset.@success == other.__isset.@success) && ((!__isset.@success) || (global::System.Object.Equals(Success, other.Success))))
            && ((__isset.@e == other.__isset.@e) && ((!__isset.@e) || (global::System.Object.Equals(E, other.E))));
        }

        public override int GetHashCode() {
          int hashcode = 157;
          unchecked {
            if((Success != null) && __isset.@success)
            {
              hashcode = (hashcode * 397) + Success.GetHashCode();
            }
            if((E != null) && __isset.@e)
            {
              hashcode = (hashcode * 397) + E.GetHashCode();
            }
          }
          return hashcode;
        }

        public override string ToString()
        {
          var tmp155 = new StringBuilder("RunQuery_result(");
          int tmp156 = 0;
          if((Success != null) && __isset.@success)
          {
            if(0 < tmp156++) { tmp155.Append(", "); }
            tmp155.Append("Success: ");
            Success.ToString(tmp155);
          }
          if((E != null) && __isset.@e)
          {
            if(0 < tmp156++) { tmp155.Append(", "); }
            tmp155.Append("E: ");
            E.ToString(tmp155);
          }
          tmp155.Append(')');
          return tmp155.ToString();
        }
      }


      public partial class SetConfigValue_args : TBase
      {

        public string Key { get; set; } = string.Empty;

        public global::QueryCat.Plugins.Sdk.VariantValue? Value { get; set; }

        public SetConfigValue_args()
        {
        }

        public SetConfigValue_args(string @key, global::QueryCat.Plugins.Sdk.VariantValue? @value) : this()
        {
          this.Key = @key;
          this.Value = @value;
        }

        public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
          iprot.IncrementRecursionDepth();
          try
          {
            bool isset_key = false;
            bool isset_value = false;
            TField field;
            await iprot.ReadStructBeginAsync(cancellationToken);
            while (true)
            {
              field = await iprot.ReadFieldBeginAsync(cancellationToken);
              if (field.Type == TType.Stop)
              {
                break;
              }

              switch (field.ID)
              {
                case 1:
                  if (field.Type == TType.String)
                  {
                    Key = await iprot.ReadStringAsync(cancellationToken);
                    isset_key = true;
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                case 2:
                  if (field.Type == TType.Struct)
                  {
                    Value = new global::QueryCat.Plugins.Sdk.VariantValue();
                    await Value.ReadAsync(iprot, cancellationToken);
                    isset_value = true;
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                default: 
                  await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  break;
              }

              await iprot.ReadFieldEndAsync(cancellationToken);
            }

            await iprot.ReadStructEndAsync(cancellationToken);
            if (!isset_key)
            {
              throw new TProtocolException(TProtocolException.INVALID_DATA);
            }
            if (!isset_value)
            {
              throw new TProtocolException(TProtocolException.INVALID_DATA);
            }
          }
          finally
          {
            iprot.DecrementRecursionDepth();
          }
        }

        public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
        {
          oprot.IncrementRecursionDepth();
          try
          {
            var tmp157 = new TStruct("SetConfigValue_args");
            await oprot.WriteStructBeginAsync(tmp157, cancellationToken);
            var tmp158 = new TField();
            if((Key != null))
            {
              tmp158.Name = "key";
              tmp158.Type = TType.String;
              tmp158.ID = 1;
              await oprot.WriteFieldBeginAsync(tmp158, cancellationToken);
              await oprot.WriteStringAsync(Key, cancellationToken);
              await oprot.WriteFieldEndAsync(cancellationToken);
            }
            if((Value != null))
            {
              tmp158.Name = "value";
              tmp158.Type = TType.Struct;
              tmp158.ID = 2;
              await oprot.WriteFieldBeginAsync(tmp158, cancellationToken);
              await Value.WriteAsync(oprot, cancellationToken);
              await oprot.WriteFieldEndAsync(cancellationToken);
            }
            await oprot.WriteFieldStopAsync(cancellationToken);
            await oprot.WriteStructEndAsync(cancellationToken);
          }
          finally
          {
            oprot.DecrementRecursionDepth();
          }
        }

        public override bool Equals(object? that)
        {
          if (that is not SetConfigValue_args other) return false;
          if (ReferenceEquals(this, other)) return true;
          return global::System.Object.Equals(Key, other.Key)
            && global::System.Object.Equals(Value, other.Value);
        }

        public override int GetHashCode() {
          int hashcode = 157;
          unchecked {
            if((Key != null))
            {
              hashcode = (hashcode * 397) + Key.GetHashCode();
            }
            if((Value != null))
            {
              hashcode = (hashcode * 397) + Value.GetHashCode();
            }
          }
          return hashcode;
        }

        public override string ToString()
        {
          var tmp159 = new StringBuilder("SetConfigValue_args(");
          if((Key != null))
          {
            tmp159.Append(", Key: ");
            Key.ToString(tmp159);
          }
          if((Value != null))
          {
            tmp159.Append(", Value: ");
            Value.ToString(tmp159);
          }
          tmp159.Append(')');
          return tmp159.ToString();
        }
      }


      public partial class SetConfigValue_result : TBase
      {
        private global::QueryCat.Plugins.Sdk.QueryCatPluginException? _e;

        public global::QueryCat.Plugins.Sdk.QueryCatPluginException? E
        {
          get
          {
            return _e;
          }
          set
          {
            __isset.@e = true;
            this._e = value;
          }
        }


        public Isset __isset;
        public struct Isset
        {
          public bool @e;
        }

        public SetConfigValue_result()
        {
        }

        public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
          iprot.IncrementRecursionDepth();
          try
          {
            TField field;
            await iprot.ReadStructBeginAsync(cancellationToken);
            while (true)
            {
              field = await iprot.ReadFieldBeginAsync(cancellationToken);
              if (field.Type == TType.Stop)
              {
                break;
              }

              switch (field.ID)
              {
                case 1:
                  if (field.Type == TType.Struct)
                  {
                    E = new global::QueryCat.Plugins.Sdk.QueryCatPluginException();
                    await E.ReadAsync(iprot, cancellationToken);
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                default: 
                  await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  break;
              }

              await iprot.ReadFieldEndAsync(cancellationToken);
            }

            await iprot.ReadStructEndAsync(cancellationToken);
          }
          finally
          {
            iprot.DecrementRecursionDepth();
          }
        }

        public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
        {
          oprot.IncrementRecursionDepth();
          try
          {
            var tmp161 = new TStruct("SetConfigValue_result");
            await oprot.WriteStructBeginAsync(tmp161, cancellationToken);
            var tmp162 = new TField();

            if(this.__isset.@e)
            {
              if (E != null)
              {
                tmp162.Name = "E";
                tmp162.Type = TType.Struct;
                tmp162.ID = 1;
                await oprot.WriteFieldBeginAsync(tmp162, cancellationToken);
                await E.WriteAsync(oprot, cancellationToken);
                await oprot.WriteFieldEndAsync(cancellationToken);
              }
            }
            await oprot.WriteFieldStopAsync(cancellationToken);
            await oprot.WriteStructEndAsync(cancellationToken);
          }
          finally
          {
            oprot.DecrementRecursionDepth();
          }
        }

        public override bool Equals(object? that)
        {
          if (that is not SetConfigValue_result other) return false;
          if (ReferenceEquals(this, other)) return true;
          return ((__isset.@e == other.__isset.@e) && ((!__isset.@e) || (global::System.Object.Equals(E, other.E))));
        }

        public override int GetHashCode() {
          int hashcode = 157;
          unchecked {
            if((E != null) && __isset.@e)
            {
              hashcode = (hashcode * 397) + E.GetHashCode();
            }
          }
          return hashcode;
        }

        public override string ToString()
        {
          var tmp163 = new StringBuilder("SetConfigValue_result(");
          int tmp164 = 0;
          if((E != null) && __isset.@e)
          {
            if(0 < tmp164++) { tmp163.Append(", "); }
            tmp163.Append("E: ");
            E.ToString(tmp163);
          }
          tmp163.Append(')');
          return tmp163.ToString();
        }
      }


      public partial class GetConfigValue_args : TBase
      {

        public string Key { get; set; } = string.Empty;

        public GetConfigValue_args()
        {
        }

        public GetConfigValue_args(string @key) : this()
        {
          this.Key = @key;
        }

        public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
          iprot.IncrementRecursionDepth();
          try
          {
            bool isset_key = false;
            TField field;
            await iprot.ReadStructBeginAsync(cancellationToken);
            while (true)
            {
              field = await iprot.ReadFieldBeginAsync(cancellationToken);
              if (field.Type == TType.Stop)
              {
                break;
              }

              switch (field.ID)
              {
                case 1:
                  if (field.Type == TType.String)
                  {
                    Key = await iprot.ReadStringAsync(cancellationToken);
                    isset_key = true;
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                default: 
                  await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  break;
              }

              await iprot.ReadFieldEndAsync(cancellationToken);
            }

            await iprot.ReadStructEndAsync(cancellationToken);
            if (!isset_key)
            {
              throw new TProtocolException(TProtocolException.INVALID_DATA);
            }
          }
          finally
          {
            iprot.DecrementRecursionDepth();
          }
        }

        public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
        {
          oprot.IncrementRecursionDepth();
          try
          {
            var tmp165 = new TStruct("GetConfigValue_args");
            await oprot.WriteStructBeginAsync(tmp165, cancellationToken);
            var tmp166 = new TField();
            if((Key != null))
            {
              tmp166.Name = "key";
              tmp166.Type = TType.String;
              tmp166.ID = 1;
              await oprot.WriteFieldBeginAsync(tmp166, cancellationToken);
              await oprot.WriteStringAsync(Key, cancellationToken);
              await oprot.WriteFieldEndAsync(cancellationToken);
            }
            await oprot.WriteFieldStopAsync(cancellationToken);
            await oprot.WriteStructEndAsync(cancellationToken);
          }
          finally
          {
            oprot.DecrementRecursionDepth();
          }
        }

        public override bool Equals(object? that)
        {
          if (that is not GetConfigValue_args other) return false;
          if (ReferenceEquals(this, other)) return true;
          return global::System.Object.Equals(Key, other.Key);
        }

        public override int GetHashCode() {
          int hashcode = 157;
          unchecked {
            if((Key != null))
            {
              hashcode = (hashcode * 397) + Key.GetHashCode();
            }
          }
          return hashcode;
        }

        public override string ToString()
        {
          var tmp167 = new StringBuilder("GetConfigValue_args(");
          if((Key != null))
          {
            tmp167.Append(", Key: ");
            Key.ToString(tmp167);
          }
          tmp167.Append(')');
          return tmp167.ToString();
        }
      }


      public partial class GetConfigValue_result : TBase
      {
        private global::QueryCat.Plugins.Sdk.VariantValue? _success;
        private global::QueryCat.Plugins.Sdk.QueryCatPluginException? _e;

        public global::QueryCat.Plugins.Sdk.VariantValue? Success
        {
          get
          {
            return _success;
          }
          set
          {
            __isset.@success = true;
            this._success = value;
          }
        }

        public global::QueryCat.Plugins.Sdk.QueryCatPluginException? E
        {
          get
          {
            return _e;
          }
          set
          {
            __isset.@e = true;
            this._e = value;
          }
        }


        public Isset __isset;
        public struct Isset
        {
          public bool @success;
          public bool @e;
        }

        public GetConfigValue_result()
        {
        }

        public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
          iprot.IncrementRecursionDepth();
          try
          {
            TField field;
            await iprot.ReadStructBeginAsync(cancellationToken);
            while (true)
            {
              field = await iprot.ReadFieldBeginAsync(cancellationToken);
              if (field.Type == TType.Stop)
              {
                break;
              }

              switch (field.ID)
              {
                case 0:
                  if (field.Type == TType.Struct)
                  {
                    Success = new global::QueryCat.Plugins.Sdk.VariantValue();
                    await Success.ReadAsync(iprot, cancellationToken);
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                case 1:
                  if (field.Type == TType.Struct)
                  {
                    E = new global::QueryCat.Plugins.Sdk.QueryCatPluginException();
                    await E.ReadAsync(iprot, cancellationToken);
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                default: 
                  await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  break;
              }

              await iprot.ReadFieldEndAsync(cancellationToken);
            }

            await iprot.ReadStructEndAsync(cancellationToken);
          }
          finally
          {
            iprot.DecrementRecursionDepth();
          }
        }

        public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
        {
          oprot.IncrementRecursionDepth();
          try
          {
            var tmp169 = new TStruct("GetConfigValue_result");
            await oprot.WriteStructBeginAsync(tmp169, cancellationToken);
            var tmp170 = new TField();

            if(this.__isset.@success)
            {
              if (Success != null)
              {
                tmp170.Name = "Success";
                tmp170.Type = TType.Struct;
                tmp170.ID = 0;
                await oprot.WriteFieldBeginAsync(tmp170, cancellationToken);
                await Success.WriteAsync(oprot, cancellationToken);
                await oprot.WriteFieldEndAsync(cancellationToken);
              }
            }
            else if(this.__isset.@e)
            {
              if (E != null)
              {
                tmp170.Name = "E";
                tmp170.Type = TType.Struct;
                tmp170.ID = 1;
                await oprot.WriteFieldBeginAsync(tmp170, cancellationToken);
                await E.WriteAsync(oprot, cancellationToken);
                await oprot.WriteFieldEndAsync(cancellationToken);
              }
            }
            await oprot.WriteFieldStopAsync(cancellationToken);
            await oprot.WriteStructEndAsync(cancellationToken);
          }
          finally
          {
            oprot.DecrementRecursionDepth();
          }
        }

        public override bool Equals(object? that)
        {
          if (that is not GetConfigValue_result other) return false;
          if (ReferenceEquals(this, other)) return true;
          return ((__isset.@success == other.__isset.@success) && ((!__isset.@success) || (global::System.Object.Equals(Success, other.Success))))
            && ((__isset.@e == other.__isset.@e) && ((!__isset.@e) || (global::System.Object.Equals(E, other.E))));
        }

        public override int GetHashCode() {
          int hashcode = 157;
          unchecked {
            if((Success != null) && __isset.@success)
            {
              hashcode = (hashcode * 397) + Success.GetHashCode();
            }
            if((E != null) && __isset.@e)
            {
              hashcode = (hashcode * 397) + E.GetHashCode();
            }
          }
          return hashcode;
        }

        public override string ToString()
        {
          var tmp171 = new StringBuilder("GetConfigValue_result(");
          int tmp172 = 0;
          if((Success != null) && __isset.@success)
          {
            if(0 < tmp172++) { tmp171.Append(", "); }
            tmp171.Append("Success: ");
            Success.ToString(tmp171);
          }
          if((E != null) && __isset.@e)
          {
            if(0 < tmp172++) { tmp171.Append(", "); }
            tmp171.Append("E: ");
            E.ToString(tmp171);
          }
          tmp171.Append(')');
          return tmp171.ToString();
        }
      }


      public partial class Log_args : TBase
      {
        private List<string>? _arguments;

        /// <summary>
        /// 
        /// <seealso cref="global::QueryCat.Plugins.Sdk.LogLevel"/>
        /// </summary>
        public global::QueryCat.Plugins.Sdk.LogLevel Level { get; set; } = default;

        public string Message { get; set; } = string.Empty;

        public List<string>? Arguments
        {
          get
          {
            return _arguments;
          }
          set
          {
            __isset.@arguments = true;
            this._arguments = value;
          }
        }


        public Isset __isset;
        public struct Isset
        {
          public bool @arguments;
        }

        public Log_args()
        {
        }

        public Log_args(global::QueryCat.Plugins.Sdk.LogLevel @level, string @message) : this()
        {
          this.Level = @level;
          this.Message = @message;
        }

        public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
          iprot.IncrementRecursionDepth();
          try
          {
            bool isset_level = false;
            bool isset_message = false;
            TField field;
            await iprot.ReadStructBeginAsync(cancellationToken);
            while (true)
            {
              field = await iprot.ReadFieldBeginAsync(cancellationToken);
              if (field.Type == TType.Stop)
              {
                break;
              }

              switch (field.ID)
              {
                case 1:
                  if (field.Type == TType.I32)
                  {
                    Level = (global::QueryCat.Plugins.Sdk.LogLevel)await iprot.ReadI32Async(cancellationToken);
                    isset_level = true;
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                case 2:
                  if (field.Type == TType.String)
                  {
                    Message = await iprot.ReadStringAsync(cancellationToken);
                    isset_message = true;
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                case 3:
                  if (field.Type == TType.List)
                  {
                    {
                      var _list173 = await iprot.ReadListBeginAsync(cancellationToken);
                      Arguments = new List<string>(_list173.Count);
                      for(int _i174 = 0; _i174 < _list173.Count; ++_i174)
                      {
                        string _elem175;
                        _elem175 = await iprot.ReadStringAsync(cancellationToken);
                        Arguments.Add(_elem175);
                      }
                      await iprot.ReadListEndAsync(cancellationToken);
                    }
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                default: 
                  await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  break;
              }

              await iprot.ReadFieldEndAsync(cancellationToken);
            }

            await iprot.ReadStructEndAsync(cancellationToken);
            if (!isset_level)
            {
              throw new TProtocolException(TProtocolException.INVALID_DATA);
            }
            if (!isset_message)
            {
              throw new TProtocolException(TProtocolException.INVALID_DATA);
            }
          }
          finally
          {
            iprot.DecrementRecursionDepth();
          }
        }

        public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
        {
          oprot.IncrementRecursionDepth();
          try
          {
            var tmp176 = new TStruct("Log_args");
            await oprot.WriteStructBeginAsync(tmp176, cancellationToken);
            var tmp177 = new TField();
            tmp177.Name = "level";
            tmp177.Type = TType.I32;
            tmp177.ID = 1;
            await oprot.WriteFieldBeginAsync(tmp177, cancellationToken);
            await oprot.WriteI32Async((int)Level, cancellationToken);
            await oprot.WriteFieldEndAsync(cancellationToken);
            if((Message != null))
            {
              tmp177.Name = "message";
              tmp177.Type = TType.String;
              tmp177.ID = 2;
              await oprot.WriteFieldBeginAsync(tmp177, cancellationToken);
              await oprot.WriteStringAsync(Message, cancellationToken);
              await oprot.WriteFieldEndAsync(cancellationToken);
            }
            if((Arguments != null) && __isset.@arguments)
            {
              tmp177.Name = "arguments";
              tmp177.Type = TType.List;
              tmp177.ID = 3;
              await oprot.WriteFieldBeginAsync(tmp177, cancellationToken);
              await oprot.WriteListBeginAsync(new TList(TType.String, Arguments.Count), cancellationToken);
              foreach (string _iter178 in Arguments)
              {
                await oprot.WriteStringAsync(_iter178, cancellationToken);
              }
              await oprot.WriteListEndAsync(cancellationToken);
              await oprot.WriteFieldEndAsync(cancellationToken);
            }
            await oprot.WriteFieldStopAsync(cancellationToken);
            await oprot.WriteStructEndAsync(cancellationToken);
          }
          finally
          {
            oprot.DecrementRecursionDepth();
          }
        }

        public override bool Equals(object? that)
        {
          if (that is not Log_args other) return false;
          if (ReferenceEquals(this, other)) return true;
          return global::System.Object.Equals(Level, other.Level)
            && global::System.Object.Equals(Message, other.Message)
            && ((__isset.@arguments == other.__isset.@arguments) && ((!__isset.@arguments) || (TCollections.Equals(Arguments, other.Arguments))));
        }

        public override int GetHashCode() {
          int hashcode = 157;
          unchecked {
            hashcode = (hashcode * 397) + Level.GetHashCode();
            if((Message != null))
            {
              hashcode = (hashcode * 397) + Message.GetHashCode();
            }
            if((Arguments != null) && __isset.@arguments)
            {
              hashcode = (hashcode * 397) + TCollections.GetHashCode(Arguments);
            }
          }
          return hashcode;
        }

        public override string ToString()
        {
          var tmp179 = new StringBuilder("Log_args(");
          tmp179.Append(", Level: ");
          Level.ToString(tmp179);
          if((Message != null))
          {
            tmp179.Append(", Message: ");
            Message.ToString(tmp179);
          }
          if((Arguments != null) && __isset.@arguments)
          {
            tmp179.Append(", Arguments: ");
            Arguments.ToString(tmp179);
          }
          tmp179.Append(')');
          return tmp179.ToString();
        }
      }


      public partial class Log_result : TBase
      {
        private global::QueryCat.Plugins.Sdk.QueryCatPluginException? _e;

        public global::QueryCat.Plugins.Sdk.QueryCatPluginException? E
        {
          get
          {
            return _e;
          }
          set
          {
            __isset.@e = true;
            this._e = value;
          }
        }


        public Isset __isset;
        public struct Isset
        {
          public bool @e;
        }

        public Log_result()
        {
        }

        public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
          iprot.IncrementRecursionDepth();
          try
          {
            TField field;
            await iprot.ReadStructBeginAsync(cancellationToken);
            while (true)
            {
              field = await iprot.ReadFieldBeginAsync(cancellationToken);
              if (field.Type == TType.Stop)
              {
                break;
              }

              switch (field.ID)
              {
                case 1:
                  if (field.Type == TType.Struct)
                  {
                    E = new global::QueryCat.Plugins.Sdk.QueryCatPluginException();
                    await E.ReadAsync(iprot, cancellationToken);
                  }
                  else
                  {
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  }
                  break;
                default: 
                  await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                  break;
              }

              await iprot.ReadFieldEndAsync(cancellationToken);
            }

            await iprot.ReadStructEndAsync(cancellationToken);
          }
          finally
          {
            iprot.DecrementRecursionDepth();
          }
        }

        public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
        {
          oprot.IncrementRecursionDepth();
          try
          {
            var tmp181 = new TStruct("Log_result");
            await oprot.WriteStructBeginAsync(tmp181, cancellationToken);
            var tmp182 = new TField();

            if(this.__isset.@e)
            {
              if (E != null)
              {
                tmp182.Name = "E";
                tmp182.Type = TType.Struct;
                tmp182.ID = 1;
                await oprot.WriteFieldBeginAsync(tmp182, cancellationToken);
                await E.WriteAsync(oprot, cancellationToken);
                await oprot.WriteFieldEndAsync(cancellationToken);
              }
            }
            await oprot.WriteFieldStopAsync(cancellationToken);
            await oprot.WriteStructEndAsync(cancellationToken);
          }
          finally
          {
            oprot.DecrementRecursionDepth();
          }
        }

        public override bool Equals(object? that)
        {
          if (that is not Log_result other) return false;
          if (ReferenceEquals(this, other)) return true;
          return ((__isset.@e == other.__isset.@e) && ((!__isset.@e) || (global::System.Object.Equals(E, other.E))));
        }

        public override int GetHashCode() {
          int hashcode = 157;
          unchecked {
            if((E != null) && __isset.@e)
            {
              hashcode = (hashcode * 397) + E.GetHashCode();
            }
          }
          return hashcode;
        }

        public override string ToString()
        {
          var tmp183 = new StringBuilder("Log_result(");
          int tmp184 = 0;
          if((E != null) && __isset.@e)
          {
            if(0 < tmp184++) { tmp183.Append(", "); }
            tmp183.Append("E: ");
            E.ToString(tmp183);
          }
          tmp183.Append(')');
          return tmp183.ToString();
        }
      }

    }

  }
}
